<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="/templates/ui.xhtml">

<ui:define name="head">
    <title>开发项目销售情况分析</title>
    <script type="text/javascript" src="#{request.contextPath}/UI/support/pub.js"/>
    <script type="text/javascript" language="javascript">
        document.onkeydown = function TabReplace() {
            if (event.keyCode == 13) {
                if (event.srcElement.tagName != 'BUTTON')
                    event.keyCode = 9;
                else
                    event.srcElement.click();
            }
        }
    </script>
    <style type="text/css">
        .cancel_c {
            color: #ff0000;
        }
    </style>
</ui:define>
<ui:define name="content">
<div style="margin:5px;">
<h:form id="form" enctype="multipart/form-data">
<p:growl id="msgs" showDetail="true"/>
<p:focus for="id"/>
<p:panel id="ppCondition" style="width: 100%">
    <h:panelGrid columns="2" style="width: 100%">
        <h:panelGrid id="pgCust" widgetVar="WvCust" columns="4" style="text-align: right;">
            <h:outputLabel value="纳税人识别号:" for="id" style="font-weight: bold;"/>
            <p:inputText id="id" value="#{developProjectSaleSituAnaAction.queryCondition.taxerID}"/>

            <h:outputLabel value="纳税人名称:" for="name" style="font-weight: bold;margin-left: 100px;"/>
            <p:inputText id="name" value="#{developProjectSaleSituAnaAction.queryCondition.taxerName}"/>

            <h:outputLabel value="所属日期起:" for="startDate" style="font-weight: bold"/>
            <p:inputText id="startDate" value="#{developProjectSaleSituAnaAction.queryCondition.dateStart}"
                         onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})"/>

            <h:outputLabel value="所属日期止:" for="endDate" style="font-weight: bold"/>
            <p:inputText id="endDate" value="#{developProjectSaleSituAnaAction.queryCondition.dateEnd}"
                         onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})"/>

            <h:outputLabel value="所属税务机关:" for="taxOrgan" style="font-weight: bold"/>
            <p:inputText id="taxOrgan" value="#{developProjectSaleSituAnaAction.queryCondition.taxAuthority}"/>

            <h:outputLabel value="主管税务管员:" for="taxManager" style="font-weight: bold"/>
            <p:inputText id="taxManager" value="#{developProjectSaleSituAnaAction.queryCondition.taxManager}"/>
        </h:panelGrid>
        <h:panelGrid style="width:10%">
            <p:commandButton id="qryBtn" value="查 询" actionListener="#{developProjectSaleSituAnaAction.query()}"
                             style="font-size: 14px;width: 80px;" update="tabSum,msgs">
            </p:commandButton>
            <p:commandButton id="resetBtn" type="reset" value="重 置"
                             style="font-size: 14px;width: 80px;">
            </p:commandButton>
        </h:panelGrid>
    </h:panelGrid>
</p:panel>

<p:ajaxStatus style="width:16px;height:16px;">
    <f:facet name="start">
        <h:graphicImage value="/images/ajaxloading.gif"/>
    </f:facet>
    <f:facet name="complete">
        <h:outputText value=""/>
    </f:facet>
</p:ajaxStatus>
<p:dataTable id="tabSum" style="width:100%;"
             value="#{developProjectSaleSituAnaAction.houseSaleSituAnaInfos}"
             var="houseSaleSituAnaInfo"
             rowKey="#{houseSaleSituAnaInfo.pkid}"
             selectionMode="single"
             selection="#{developProjectSaleSituAnaAction.houseSaleSituAnaInfoSelected}"
             paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
             paginator="true"
             paginatorPosition="bottom"
             rows="15"
             rowsPerPageTemplate="100,50,30,15,5"
             emptyMessage="数据记录为空...">

    <p:ajax event="rowSelect" listener="#{developProjectSaleSituAnaAction.updateSaledAsset()}"
            update=":form:tabDetail,:form:houseSaleCasePie"/>

    <p:column style="text-align:center" sortBy="#{houseSaleSituAnaInfo.assetCost}">
        <f:facet name="header">
            <h:outputText value="开发项目"/>
        </f:facet>
        <h:outputText value="#{houseSaleSituAnaInfo.assetCost}"/>
    </p:column>

    <p:column style="text-align:center" sortBy="#{houseSaleSituAnaInfo.NSRSBH}">
        <f:facet name="header">
            <h:outputText value="纳税人识别号"/>
        </f:facet>
        <h:outputText value="#{houseSaleSituAnaInfo.NSRSBH}"/>
    </p:column>

    <p:column style="text-align:center" filterBy="#{houseSaleSituAnaInfo.NSRMC}" filterMatchMode="contains">
        <f:facet name="header">
            <h:outputText value="纳税人名称"/>
        </f:facet>
        <h:outputText value="#{houseSaleSituAnaInfo.NSRMC}"/>
    </p:column>

    <p:column style="text-align:center" sortBy="#{houseSaleSituAnaInfo.COUNT}">
        <f:facet name="header">
            <h:outputText value="房产数量"/>
        </f:facet>
        <h:outputText value="#{houseSaleSituAnaInfo.COUNT}"/>
    </p:column>

    <p:column style="text-align:center" sortBy="#{houseSaleSituAnaInfo.area}">
        <f:facet name="header">
            <h:outputText value="面积"/>
        </f:facet>
        <h:outputText value="#{houseSaleSituAnaInfo.area}">
            <f:convertNumber pattern="##################.##"/>
        </h:outputText>
    </p:column>

    <p:column style="text-align:center" sortBy="#{houseSaleSituAnaInfo.saleCount}">
        <f:facet name="header">
            <h:outputText value="销售数量"/>
        </f:facet>
        <h:outputText value="#{houseSaleSituAnaInfo.saleCount}"/>
    </p:column>

    <p:column style="text-align:center" sortBy="#{houseSaleSituAnaInfo.scale}">
        <f:facet name="header">
            <h:outputText value="比例"/>
        </f:facet>
        <h:outputText value="#{houseSaleSituAnaInfo.scale}">
            <f:convertNumber type="number" pattern="##0.00"/>
        </h:outputText>%
    </p:column>

    <p:column style="text-align:center" filterBy="#{houseSaleSituAnaInfo.taxAuthority}" filterMatchMode="contains">
        <f:facet name="header">
            <h:outputText value="税务机关"/>
        </f:facet>
        <h:outputText value="#{houseSaleSituAnaInfo.taxAuthority}"/>
        <f:facet name="footer">
            <h:outputText value="笔数：#{fn:length(developProjectSaleSituAnaAction.houseSaleSituAnaInfos)}"/>
        </f:facet>
    </p:column>

    <p:column style="text-align:center" filterBy="#{houseSaleSituAnaInfo.taxerManager}" filterMatchMode="contains">
        <f:facet name="header">
            <h:outputText value="税管员"/>
        </f:facet>
        <h:outputText value="#{houseSaleSituAnaInfo.taxerManager}"/>
        <f:facet name="footer">
            <h:commandLink>
                <h:outputText value="[导出数据]"/>
                <p:dataExporter type="xls" target="tabSum" fileName="fdcxsqkhz"/>
            </h:commandLink>
        </f:facet>
    </p:column>
</p:dataTable>
<br/>
<p:separator/>

<p:panelGrid columns="2">
    <p:dataTable id="tabDetail" style="width:500px;"
                 value="#{developProjectSaleSituAnaAction.saledCaseList}"
                 var="saledCase"
                 rowKey="#{saledCase.pkid}"
                 selectionMode="single"
                 selection="#{developProjectSaleSituAnaAction.saledCaseSelected}"
                 paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                 paginator="true"
                 paginatorPosition="bottom"
                 rows="15"
                 rowsPerPageTemplate="100,50,30,15,5"
                 emptyMessage="数据记录为空...">
        <f:facet name="header">
            <h:outputText value="销售情况"/>
            <h:outputText style="margin-left: 20px;" value="笔数：#{fn:length(developProjectSaleSituAnaAction.saledCaseList)}"/>
            <h:commandLink style="text-align: right;margin-left: 20px;">
                <h:outputText value="[导出数据]"/>
                <p:dataExporter type="xls" target="tabDetail" fileName="xxqk"/>
            </h:commandLink>
        </f:facet>

        <p:ajax event="rowSelect" listener="#{developProjectSaleSituAnaAction.updatethAssetDetail()}"
                update=":form:thAssetDetailTab" oncomplete="thAssetDetail.show()"/>

        <p:column style="text-align:center">
            <f:facet name="header">
                <h:outputText value="房产性质"/>
            </f:facet>
            <h:outputText value="#{saledCase.houseNature}"/>
            <f:facet name="footer">
                <h:outputText value="总 计"/>
            </f:facet>
        </p:column>

        <p:column style="text-align:center">
            <f:facet name="header">
                <h:outputText value="总户数"/>
            </f:facet>
            <h:outputText value="#{saledCase.houseCount}"/>

            <f:facet name="footer">
                <h:outputText value="#{developProjectSaleSituAnaAction.houseSaleSituAnaInfoSelected.COUNT}"/>
            </f:facet>

        </p:column>

        <p:column style="text-align:center">
            <f:facet name="header">
                <h:outputText value="已卖出数"/>
            </f:facet>
            <h:outputText value="#{saledCase.saledCount}"/>
            <f:facet name="footer">
                <h:outputText value="#{developProjectSaleSituAnaAction.houseSaleSituAnaInfoSelected.saleCount}"/>
            </f:facet>
        </p:column>

        <p:column style="text-align:center">
            <f:facet name="header">
                <h:outputText value="比例"/>
            </f:facet>
            <h:outputText value="#{saledCase.scale}">
                <f:convertNumber type="number" pattern="##0.00"/>
            </h:outputText>%
            <f:facet name="footer">
                <h:outputText value="#{developProjectSaleSituAnaAction.houseSaleSituAnaInfoSelected.scale}">
                    <f:convertNumber type="number" pattern="##0.00"/>
                </h:outputText>
            </f:facet>
        </p:column>
    </p:dataTable>
    <p:pieChart id="houseSaleCasePie"
                value="#{developProjectSaleSituAnaAction.pieModel}" legendPosition="w"
                showDataLabels="true" title="房产性质对比图"
                style="width:260px;height:260px;font-weight: bold;font-size: 12px;"/>

</p:panelGrid>

<p:dialog id="thAssetDetail" widgetVar="thAssetDetail" header="已卖出房产明细" modal="true" showEffect="drop"
          hideEffect="drop" width="800">
    <p:dataTable id="thAssetDetailTab" style="width:100%;"
                 value="#{developProjectSaleSituAnaAction.thAssetSelfs}"
                 var="thAssetSelf"
                 paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                 paginator="true"
                 paginatorPosition="bottom"
                 rows="15"
                 rowsPerPageTemplate="100,50,30,15,5"
                 rowStyleClass="#{developProjectSaleSituAnaAction.canceled(thAssetSelf.assetId) ? 'cancel_c' : ''}"
                 emptyMessage="数据记录为空...">

        <p:column style="text-align:center" sortBy="#{thAssetSelf.assetId}">
            <f:facet name="header">
                <h:outputText value="房产编号"/>
            </f:facet>
            <h:outputText value="#{thAssetSelf.assetId}"/>
        </p:column>
        <p:column style="text-align:center" sortBy="#{thAssetSelf.flag}">
            <f:facet name="header">
                <h:outputText value="目前状态"/>
            </f:facet>
            <h:outputText value="#{thAssetSelf.flag}"/>
        </p:column>
        <p:column style="text-align:center">
            <f:facet name="header">
                <h:outputText value="房产性质"/>
            </f:facet>
            <h:outputText value="#{thAssetSelf.houseType}"/>
        </p:column>
        <p:column style="text-align:center" sortBy="#{thAssetSelf.assetCost}">
            <f:facet name="header">
                <h:outputText value="楼盘"/>
            </f:facet>
            <h:outputText value="#{thAssetSelf.assetCost}"/>
        </p:column>
        <p:column style="text-align:center" sortBy="#{thAssetSelf.building}">
            <f:facet name="header">
                <h:outputText value="楼座"/>
            </f:facet>
            <h:outputText value="#{thAssetSelf.building}"/>
        </p:column>
        <p:column style="text-align:center" sortBy="#{thAssetSelf.assetCell}">
            <f:facet name="header">
                <h:outputText value="单元"/>
            </f:facet>
            <h:outputText value="#{thAssetSelf.assetCell}"/>
        </p:column>
        <p:column style="text-align:center" sortBy="#{thAssetSelf.assetStory}">
            <f:facet name="header">
                <h:outputText value="楼层"/>
            </f:facet>
            <h:outputText value="#{thAssetSelf.assetStory}"/>
        </p:column>
        <p:column style="text-align:center" sortBy="#{thAssetSelf.assetRoom}">
            <f:facet name="header">
                <h:outputText value="房号"/>
            </f:facet>
            <h:outputText value="#{thAssetSelf.assetRoom}"/>
            <f:facet name="footer">
                <h:outputText value="笔数：#{fn:length(developProjectSaleSituAnaAction.thAssetSelfs)}"/>
            </f:facet>
        </p:column>
        <p:column style="text-align:center" sortBy="#{thAssetSelf.assetArea}">
            <f:facet name="header">
                <h:outputText value="面积"/>
            </f:facet>
            <h:outputText value="#{thAssetSelf.assetArea}"/>
            <f:facet name="footer">
                <h:commandLink>
                    <h:outputText value="[导出数据]"/>
                    <p:dataExporter type="xls" target="thAssetDetailTab" fileName="fcmx"/>
                </h:commandLink>
            </f:facet>
        </p:column>
    </p:dataTable>
</p:dialog>
</h:form>
</div>
</ui:define>
</ui:composition>

